//
//  RecordModel.m
//  20240823
//
//  Created by 张伟 on 2024/8/28.
//

#import "CallRecordModel.h"

@implementation CallRecordModel

NSString * timeStringFromSeconds(NSInteger seconds) {
    NSInteger hours = seconds / 3600;
    NSInteger minutes = (seconds % 3600) / 60;
    NSInteger remainingSeconds = seconds % 60;

    NSMutableString *timeString = [NSMutableString string];

    if (hours > 0) {
        [timeString appendFormat:@"%ld时", (long)hours];
    }
    
    if (minutes > 0 || hours > 0) { // 如果有小时，分钟即使为0也要显示
        [timeString appendFormat:@"%ld分", (long)minutes];
    }
    
    [timeString appendFormat:@"%ld秒", (long)remainingSeconds];
    return timeString;
}

- (NSString *)callDurationString {
    return timeStringFromSeconds(self.duration);
}

@end
